package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.ContractBo;
import com.jackiechancinema.ssm.bo.DailyBo;
import com.jackiechancinema.ssm.entity.Contract;
import com.jackiechancinema.ssm.entity.Daily;
import com.jackiechancinema.ssm.service.Inte.ContractService;
import com.jackiechancinema.ssm.service.Inte.DailyService;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/api/daily/")
public class DailyController {
    @Autowired
    private DailyService dailyService;


    //新增
    @PostMapping("save")
    public R save(Daily daily){
        return dailyService.insert(daily);
    }

    //查询
    @GetMapping("page")
    public PageVo<Daily> page(DailyBo dailyBo){
        return dailyService.queryPage(dailyBo);
    }

    //删除
    @PostMapping("del")
    public R delete(int id){
        return dailyService.deleteById(id);
    }

    //批量删除
    @PostMapping("batchDel")
    public R batchDel(@RequestBody List<Daily> dailys){
        return dailyService.deleteBatch(dailys);
    }

    //修改
    @PostMapping("edit")
    public R edit(Daily daily){
        return dailyService.update(daily);
    }
    //批量导入
    @PostMapping("batchadd")
    public R batchAdd(MultipartFile file){
        return dailyService.insertBatch(file);
    }
    //下载，导出excel表格
    @GetMapping("download")
    public void download(DailyBo bo, HttpServletResponse response){
        dailyService.exportExcel(bo,response);
    }
}
